package com.lirh.mysql.controller;


import com.lirh.mysql.entity.Tiezi;
import com.lirh.mysql.service.TieziServiceImpl;
import com.lirh.mysql.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/tiezi")
public class TieziController {
    @Autowired
    private TieziServiceImpl tieziService;

    @GetMapping("/get")
    public R getTiezi(){
        List<Map<String, Object>> tiezis = tieziService.getTiezis();
        return R.ok().put("data",tiezis);
    }
    @GetMapping("/get/{id}")
    public R getTiezibyid(@PathVariable("id")int id){
        Tiezi tiezisbyid = tieziService.getTiezisbyid(id);
        return R.ok().put("data",tiezisbyid);
    }
    @PostMapping("/insert")
    public R insert(@RequestBody Tiezi tiezi){
        String res=tieziService.insert(tiezi);
        return R.ok().put("data",res);
    }
}
